package com.deloitte.payrollmgtsys.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.deloitte.payrollmgtsys.util.DashboardConstants;

/**
 * Responsible for creating task view.
 * 
 * @author muwang
 *
 */
@Controller
@RequestMapping("/task")
public class TaskController {
	
	@RequestMapping("")
	public void getMyTask(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		request.setAttribute("current_page", DashboardConstants.TASK_PAGE);
		request.getRequestDispatcher("/pages/tasks.jsp").forward(request, response);
	}
	
	@RequestMapping("/{id}")
	public void getTask(@PathVariable("id") int id, HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		request.setAttribute("curTaskId", id);
		request.setAttribute("current_page", DashboardConstants.TASK_DETAIL_PAGE);
		request.getRequestDispatcher("/pages/taskDetail.jsp").forward(request, response);
	}
}
